<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app" >
        <parent></parent>
    </div>
    
    </div>
    <template id="child">
        <div>
            <button @click='click'>Send</button>
            <input type="text" v-model="message">
        </div>
    </template>
    <script src="vue.js"></script>
    <script>
        Vue.component('parent',{
            template:'<div><child @childFn="transContent"></child>'+ 
                '子组件传来的值:{{message}}</div>',
            data(){
                return{
                    message:''
                }
            },
            methods:{
                transContent(payload){
                    this.message=payload
                }
            }
        })
        //child组件
        Vue.component('child',{
            template:'#child',
            data (){
                return{
                    message:'子组件信息'
                }
            },
            methods:{
                click(){
                    this.$emit('childFn',this.message);
                }
            }
        })
        var vm=new Vue({el:'#app'})
    </script>
</body>
</html>